package com.zz.service;

import com.zz.entity.User;
import com.zz.repository.UserRepository;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.PageRequest;
import org.springframework.data.domain.Pageable;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;

@Service
public class UserService {
	@Resource
    UserRepository userRepository;

	
	public User findByNameAndPwd(String name, String pwd){
		return userRepository.findByNameAndPwd(name, pwd);
	};
	
	
	public User save(User user){
		return userRepository.save(user);
	};
	
	
	public Page<User> findAll(String page, String limit){
		Pageable pageable = PageRequest.of(Integer.parseInt(page), Integer.parseInt(limit));
		Page<User> pageinfo=userRepository.findAll(pageable);
		return pageinfo;
	}
}
